package cj.web.admin.controllers;

import javax.servlet.http.HttpServletRequest;

import net.paoding.rose.web.annotation.Param;
import net.paoding.rose.web.annotation.Path;
import net.paoding.rose.web.annotation.rest.Get;
import net.paoding.rose.web.annotation.rest.Post;
import net.paoding.rose.web.var.Model;
import net.sf.json.JSONObject;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;

import cj.web.admin.constants.Constants;
import cj.web.admin.dao.CategoryDAO;
import cj.web.admin.domain.Category;

@Path("/category")
public class CategoryController{

	private static Logger logger = Logger.getLogger(CategoryController.class.getName());
	
	@Autowired
	private CategoryDAO categoryDao;
	
	@Get("show")
	public String show(Model model,Category category) {
	
		return "";
	}

	@Post("getList")
	public String queryList(Category category) {
	
		JSONObject jo = new JSONObject();
		return "@"+jo.toString();
	}
	
	@Get("createPage")
	public String createPage()
	{
		return "";
	}
	
	@Post("create")
	public String create(Model model,Category category,HttpServletRequest request)
	{
		JSONObject jo = new JSONObject();
		jo.put("returnFlag", Constants.returnObj.returnFlag_true);
		
		try {
			
		} catch (Exception e) {
			// TODO: handle exception
			jo.put("returnFlag", Constants.returnObj.returnFlag_flase);
		}
		
		return "@"+jo.toString();
	}
	
	@Get("edit")
	public String edit(Model model,@Param("id") int id)
	{
		return "";
	}
	
	@Post("update")
	public String update(Model model,Category category,HttpServletRequest request)
	{
		JSONObject jo = new JSONObject();
		jo.put("returnFlag", Constants.returnObj.returnFlag_true);
		
		try {
			
		} catch (Exception e) {
			// TODO: handle exception
			jo.put("returnFlag", Constants.returnObj.returnFlag_flase);
		}
		
		return "@"+jo.toString();
	}
	
	@Get("deleteById")
	public String deleteById(Model model,@Param("id") int id)
	{
		return "r:show";
	}
}
